#ifndef TCPCONN_H
#define TCPCONN_H

#include "connect.h"
#include "TDBInterface.h"

class ThreeCardPokerGame;
class ThreeCardPokerHand;

class ThreeCardConnection : public Connection
{
	public:
		ThreeCardConnection(Server* server, SOCKET client);
		~ThreeCardConnection();

		void msgStart();
		void msgAdd(uint8 Byte);
		void msgAdd(int32 SignedLong);
		uint8* msgGetBuf();
		void msgReleaseBuf(int32 Amt);
		void msgEnd();

        // kharmon.  01-31-06.  #5862.
        uint8   getAnteBonusPayTable()  { return anteBonusPayTable; };
        uint8   getSideBetPayTable()    { return sideBetPayTable; };
        TDBInterface * getDBInterface() { return m_pDBInterface; }

        void	trackaddBadPacket(int32 error_reason, char MessageType, char *msgbuf, int32 msglen);
		int32	trackValidateLogin();
		int32	trackValidateSession();

		// CSN-7075: New Authentication
		void	trackLogoutSession();

        #ifdef FORCEDSHOE 
        String  GetPID() {return m_pid;}
        #endif


	protected:
		bool8	getResponse();

		void	handleLogin(int32 length, int32 err);

		void	sendStopMsg();

		bool8	parseCasinoLogin(int32, int32*);
		bool8	parseUnicodeCasinoLogin(int32, int32*);
		void	removeCasinoSpecific();

		int32	encode(uint8*, uint8*, int32);
		int32	decode(uint8*, uint8*, int32);

		int32	msgRemove(uint8*, int32*);
		void	allocateXMLTranslator( XMLTranslator** target );

	public:
		void	gameDone();

	protected:
		int32 loggedOn;
        TGame* game;
		void* casinoSpecific;
		int32 minBet, maxBet;
		int32 compFactor;
		int32 msglen;
		uint8 msgbuf[256];
        uint8 anteBonusPayTable, sideBetPayTable;

        // kharmon.  01-31-06.  #5862.
        TriCardGameId m_eGameId;        // indicates which game the user is connected to.
        TDBInterface *m_pDBInterface;   // Used to access the database

        const static int32 VERSION1_HEADER_SIZE;    // size of the version 1 header for the login message.

        #ifdef FORCEDSHOE       //RPF 20100317 When forcing the shue now filter by pid
        String  m_pid;
        #endif

	// [AO 2008-01-16] Refactoring for HA
	private:
		bool ValidateSession();
};

#endif
